package com.chnbst.bstyun.service.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.chnbst.bstyun.core.base.BaseService;
import com.chnbst.bstyun.core.common.helper.DaoHelper;
import com.chnbst.bstyun.model.pojo.Area;
import com.chnbst.bstyun.model.pojo.City;
import com.chnbst.bstyun.model.pojo.Province;
import com.chnbst.bstyun.service.PlaceService;

/**
 * @author zqh
 * @date 2014年9月23日
 * 
 */
@Transactional
@Service
public class PlaceServiceImpl extends BaseService implements PlaceService {

	//声明日志对象 logback
	private final static Logger logger = LoggerFactory.getLogger(PlaceServiceImpl.class);
	private final static String province_nameSpace = "com.chnbst.bstyun.mapper.ProvinceMapper";
	private final static String city_nameSpace = "com.chnbst.bstyun.mapper.CityMapper";
	private final static String area_nameSpace = "com.chnbst.bstyun.mapper.AreaMapper";

	@SuppressWarnings("unchecked")
	@Override
	public List<Province> getProvinceList() {
		return (List<Province>)DaoHelper.list(province_nameSpace, "selectProvinceList", null);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<City> getCityByPcode(Integer provinceCode) {
		return (List<City>) DaoHelper.list(city_nameSpace, "selectByProvinceCode", provinceCode);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Area> getAreaByCcode(Integer cityCode) {
		return (List<Area>) DaoHelper.list(area_nameSpace, "selectByCityCode", cityCode);
	}

	@Override
	public Province getProvinceByPcode(Integer provinceCode) {
		return (Province)DaoHelper.query(province_nameSpace, "selectProvinceByPcode", provinceCode);
	}

	@Override
	public City getCityByCcode(Integer cityCode) {
		return (City)DaoHelper.query(city_nameSpace, "selectBycityCode", cityCode);
	}

	@Override
	public Area getAreaByAcode(Integer areaCode) {
		return (Area)DaoHelper.query(area_nameSpace, "selectAreaByAreaCode", areaCode);
	}

}
